home *** CD-ROM | disk | FTP | other *** search
-
- /******************************************************************************
-
- MODULE
- SharedCode.c
-
- DESCRIPTION
- XDME Module
- That module keeps some functions, which are shaerd by
- different other modules.
-
- NOTES
-
- BUGS
- none known
-
- TODO
- tell me
-
- EXAMPLES
-
- SEE ALSO
-
- INDEX
-
- HISTORY
- 24-09-94 b_noll created
- 01-10-94 b_noll introduced DEFMESSAGE
-
- ******************************************************************************/
-
-
- /**************************************
- Includes
- **************************************/
-
- #define AVL_H 1
- #include "defs.h"
-
- /**************************************
- Global Variables
- **************************************/
-
-
- /**************************************
- Internal Defines & Structures
- **************************************/
-
-
- /**************************************
- Internal Variables
- **************************************/
-
-
- /**************************************
- Internal Prototypes
- **************************************/
-
-
- /**************************************
- Macros
- **************************************/
-
-
- /**************************************
- Implementation
- **************************************/
-
- Prototype int is_Aborted (void);
- int is_Aborted (void)
- {
- return GETF_ABORTCOMMAND( Ep );
- } /* is_aborted */
-
- Prototype void set_Abortion (int val);
- void set_Abortion (int val)
- {
- SETF_ABORTCOMMAND( Ep, val );
- } /* set_abortion */
-
- Prototype void no_Memory (void);
- void no_Memory (void)
- {
- nomemory();
- } /* no_Memory */
-
-
- Prototype APTR active_window (void);
- APTR active_window (void)
- {
- return Ep->win;
- } /* active_window */
-
-
- int strpos (const char * str, int chr) {
- char *in;
- if ((in = strchr(str, chr)))
- return (int)(in - str);
- return -1;
- }
-
- Prototype void strtrans (char * str, const char *find, const char *rep);
- void strtrans (char * str, const char *find, const char *rep)
- {
- while (str = strpbrk(str, find)) {
- *str = rep[strpos(find, *str)];
- ++str;
- } /* while */
- } /* strtrans */
-
-
-
-
- //Prototype int writefile (const char *, int (*writefunc)(FILE *, APTR), APTR);
- static int writefile (const char *filename, int (*writefunc)(FILE *, APTR), APTR data)
- {
- FILE * fo;
-
- if ((fo = fopen(filename, "w"))) {
- int rv;
- rv = (*writefunc)(fo, data);
- fclose(fo);
- return rv;
- } else {
- DEFMESSAGE( _SHARED_cant_open_outfile, "%s:\nCan't open file %s for output" )
- error (_SHARED_cant_open_outfile, av[0], filename);
- return RET_FAIL;
- } /* if */
- } /* writefile */
-
- Prototype int std_writefile (int (*writefunc)(FILE *, APTR), APTR);
- int std_writefile (int (*writefunc)(FILE *, APTR), APTR data)
- {
- return writefile (av[1], writefunc, data);
- } /* std_writefile */
-
-
- //Prototype int readfile (const char *, int (*readfunc)(FILE *, APTR), APTR);
- static int readfile (const char *filename, int (*readfunc)(FILE *, APTR), APTR data)
- {
- FILE * fi;
-
- if ((fi = fopen(filename, "r"))) {
- int rv;
- rv = (*readfunc)(fi, data);
- fclose(fi);
- return rv;
- } else {
- DEFMESSAGE( _SHARED_cant_open_infile, "%s:\nCan't open file %s for input" )
- error (_SHARED_cant_open_infile, av[0], filename);
- return RET_FAIL;
- } /* if */
- } /* readfile */
-
- Prototype int std_readfile (int (*readfunc)(FILE *, APTR), APTR);
- int std_readfile (int (*readfunc)(FILE *, APTR), APTR data)
- {
- return readfile (av[1], readfunc, data);
- } /* std_readfile */
-
- Prototype int buffered_do_command (const char *str);
- int buffered_do_command (const char *str) {
- char* buffer = strdup(str); /* allocate a buffer and copy the command into that buffer */
- if (buffer) {
- int retval;
- retval = do_command(buffer); /* execute the buffer */
- free(buffer); /* and then free it again */
- return retval;
- } else
- nomemory();
- return RET_FAIL;
- } /* buffered_do_command */
-
- DEFMESSAGE( __on, "ON" )
- DEFMESSAGE( __off, "OFF" )
-
-
- Prototype int NodeStringComparison (struct Node *n1, STRPTR str);
- int NodeStringComparison (struct Node *n1, STRPTR str)
- {
- //printf ("NS: n/%08lx/`%s' <> s/%08lx/`%s'\n", n1, n1->ln_Name, str, str);
- return strcmp (n1->ln_Name, str);
- } /* NodeStringComparison */
-
- Prototype int NodeNodeComparison (struct Node *n1, struct Node *n2);
- int NodeNodeComparison (struct Node *n1, struct Node *n2)
- {
- //printf ("NN: n/%08lx/`%s' <> n/%08lx/`%s'\n", n1, n1->ln_Name, n2, n2->ln_Name);
- return strcmp (n1->ln_Name, n2->ln_Name);
- } /* NodeNodeComparison */
-
-
-
- /******************************************************************************
- ***** END SharedCode.c
- ******************************************************************************/
-
-
- int iAVL_Append (APTR x, APTR y, APTR z);
- int iAVL_Remove (APTR x, APTR y, APTR z);
- int iAVL_Find (APTR x, APTR y, APTR z);
- int iAVL_Append (APTR x, APTR y, APTR z)
- {
- int AVL_Append (APTR x, APTR z);
- return AVL_Append (x,z);
- }
-
- int iAVL_Find (APTR x, APTR y, APTR z)
- {
- int AVL_Find (APTR x, APTR z);
- return AVL_Find (x,z);
- }
-
- int iAVL_Remove (APTR x, APTR y, APTR z)
- {
- int AVL_Remove (APTR x, APTR z);
- return AVL_Remove (x,z);
- }
-
-
-